package com.usian.api;

import com.usian.pojo.Emp;
import com.usian.query.EmpDto;
import com.usian.utils.PageResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "provider") //被调用方的服务名
public interface ProviderFeign {

    /**
     * 传参 get
     * ？传参 feign参数 一定要加@requestParam,多个参数时每个参数都加该注解 405 feign找不到
     * / 传参  @PathVariable 注解 保证和生产者controller中方法一致
     * 复杂类型 对象  @requestBody
     * @return
     */

    @RequestMapping("/provider/findAll")
    public List<Emp> findAll();

    @GetMapping("/provider/findById")
    public Emp findByIds(@RequestParam int id);

    @GetMapping("/provider/findByIdAndName/{id}/{name}")
    public Emp findByIdAndName(@PathVariable int id, @PathVariable String name);

    @PostMapping("/provider/saveEmp")
    public String saveEmp(@RequestBody  Emp emp);

    @RequestMapping("/provider/findByEmpDto")
    public PageResult<Emp> findByEmpDto(@RequestBody EmpDto empDto);

    @GetMapping("/provider/findById/{id}")
    public Emp findById(@PathVariable int id);

    @PostMapping("/provider/updateEmp")
    public String updateEmp(@RequestBody  Emp emp);

    @GetMapping("/provider/deleteById")
    public String deleteById(@RequestParam Integer id);

}
